import Moment from 'moment'

const isNullOrEmpty = function(val) {
	if (val == null || val == "" || typeof(val) == undefined) {
		return true;
	} else {
		return false;
	}
}

//时间戳过滤器
const formatDate = function(value) {
	if (!isNullOrEmpty(value)) {
		return Moment(value).format('YYYY-MM-DD')
	}
}

const isTF = function(value) {
	if (!isNullOrEmpty(value)) {
		if (value) {
			return "是"
		} else {
			return "否"
		}
	}
}

const formatDecimals = function(value) {
	return Number(value).toFixed(0)
}

export {
	formatDate,
	isTF,
	formatDecimals
}
